package com.example.skin_whitening_ndk;

import android.graphics.Bitmap;
import android.graphics.Color;

/**
 * Created by jiang at 2021/9/26
 */
public class JavaImageRGB {

    private  static int Pixel_Alpha=0;
    private static int Pixel_Red=0;
    private  static int Pixel_Green=0;
    private  static int Pixel_Blue=0;

    public static Bitmap getImageBitmap(Bitmap src){
        int width=src.getWidth();
        int height=src.getHeight();
        Bitmap dst=Bitmap.createBitmap(width,height, Bitmap.Config.ARGB_8888);

        int alpha,red,green,blue;

        int Pixel_color;
        //依次拿到每一个像素点
        for (int x=0;x<width;x++){
            for (int y=0;y<height;y++){
                Pixel_color= src.getPixel(x,y);
                alpha= Color.alpha(Pixel_color);//得到透明度
                red=Color.red(Pixel_color);//得到红色
                green=Color.green(Pixel_color);//得到绿色
                blue=Color.blue(Pixel_color);//得到蓝色

                //合成像素
                dst.setPixel(x,y,Color.argb(alpha,0,green,blue));
            }
        }
        return dst;
    }
}
